﻿using System;
using JetBrains.Annotations;
using Kaleida.ServiceMonitor.Model.Runtime;

namespace Kaleida.ServiceMonitor.Model.ScriptDirectives
{
	public class ColoursDirective : IScriptDirective
	{
		private readonly IStateColourationStrategy strategy;

        public ColoursDirective([NotNull] string specificationString)
        {
        	if (specificationString == null) throw new ArgumentNullException("specificationString");

            strategy = StateColourationStrategy.Parse(specificationString);
        }

		public CompiledNode Apply([NotNull] CompiledScriptModule module)
        {
            if (module == null) throw new ArgumentNullException("module");

            module.ColourationStrategy = strategy;
            return new CompiledNode(module);
        }
    }
}
